FROM node

# 使用淘宝 NPM 镜像（国内机器构建推荐启用）
# RUN npm config set registry https://registry.npm.taobao.org/

ARG NoNpmInstall
ENV NoNpmInstall=${NoNpmInstall}

# 假设外部已经npm初始化过了
ADD . /src
WORKDIR /src
RUN if [ "$NoNpmInstall" != "1" ]; then npm install; fi
RUN npm run buildTS

# clean
RUN npm prune --production

# move
RUN rm -rf /app \
    && mkdir /app/ \
    && mv dist /app/dist \
    && mv node_modules /app/ \
    && mv gf.*.config.json /app/ \
    && rm -rf /src

# ENV
ENV NODE_ENV production

EXPOSE 7801/TCP 7801/UDP

WORKDIR /app
CMD node dist/index.js